package com.muyu.user.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.muyu.common.core.web.page.PageQueryModel;
import com.muyu.user.service.SysUserLevelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.user.mapper.SysUserLevelMapper;
import com.muyu.user.domain.SysUserLevel;
import com.muyu.user.domain.model.SysUserLevelQueryModel;
import com.muyu.user.domain.model.SysUserLevelPageQueryModel;
import com.muyu.user.domain.model.SysUserLevelSaveModel;
import com.muyu.user.domain.model.SysUserLevelEditModel;

/**
 * 用户等级Service业务层处理
 *
 * @author liuguoqiang
 * @date 2025-09-14
 */
@Slf4j
@Service
public class SysUserLevelServiceImpl extends ServiceImpl<SysUserLevelMapper, SysUserLevel>  implements SysUserLevelService {

    /**
     * 查询用户等级列表
     *
     * @param pageQueryModel 用户等级
     * @return 用户等级
     */
    @Override
    public PageQueryModel<SysUserLevelPageQueryModel> pageQuery(SysUserLevelQueryModel pageQueryModel) {
        LambdaQueryWrapper<SysUserLevel> queryWrapper = new LambdaQueryWrapper<>();
                   Page<SysUserLevel> page = this.page(pageQueryModel.buildPage(), queryWrapper);
        return PageQueryModel.of(page).cover(SysUserLevelPageQueryModel::infoBuild);
    }


    /**
     * 查询用户等级列表
     *
     * @param pageQueryModel 用户等级
     * @return 用户等级
     */
    @Override
    public List<SysUserLevel> exportList(SysUserLevel pageQueryModel) {
        LambdaQueryWrapper<SysUserLevel> queryWrapper = new LambdaQueryWrapper<>();
                   return this.list(queryWrapper);
    }

    /**
     * 用户等级添加
     *
     * @param saveModel 用户等级
     * @return 用户等级集合
     */
    @Override
    public void save(SysUserLevelSaveModel saveModel){
        this.save(SysUserLevel.saveModelBuild(saveModel));
    }

    /**
     * 用户等级修改
     *
     * @param editModel 用户等级修改模型
     * @return 用户等级集合
     */
    @Override
    public void edit(SysUserLevelEditModel editModel){
        this.updateById(SysUserLevel.editModelBuild(editModel));
    }

    @Override
    public List<SysUserLevel> selectEnabledLevels() {
        return this.list();
    }

    /**
     * 用户等级下拉框
     * @return
     */
    @Override
    public List<SysUserLevel> getLevelOptions() {
        return this.list();
    }

}
